#!/bin/sh
#
# Author ： hbaolong@vip.qq.com
#
# Function : 生成一个HASH5的单独界面。
#
#

if [ $# -ne 0 ]; then
	echo "Usage: this is a empty shell."
	exit
fi

workdir="/Users/hbaolong/workshop/gitee/3place"

cd $workdir

have_hash_books=`find .|grep hash|xargs file|grep directory|awk -F/ '{print $2}'|sort -g `


echo "% HASH5" > index_hash5.md

echo "" >> index_hash5.md

commcode header >> index_hash5.md

for book in $have_hash_books
do
	source $book/config

	echo "" >> index_hash5.md

	echo "## "$book >> index_hash5.md

	echo "" >> index_hash5.md

	for hash5 in `ls $book/hash/*.md |sed -e "/index/d"`
	do
#		echo $hash5
		title=`grep "^%" $hash5 |sed -e "s/% //g"|sed -e "s/^ //g" `
#		echo $title
		mdfile=`echo $hash5 |sed -e "/index/d" |awk -F/ '{print $3}' |sed -e "s/.md//g"`

		echo "[$title]($url/hash/$mdfile.html)" >> index_hash5.md

		echo "" >> index_hash5.md

	done

#	echo "[$book]($url/hash/index.html)" >>index_hash5.md

	echo "" >> index_hash5.md
done

pandoc -s index_hash5.md  -o ~/workshop/hbaolong.github.io/index_hash5.html 

